import { reactive, onMounted, ref, nextTick } from 'vue'
import { StageTable, AddModel } from '@/api/01work/01type'
import { TaskPageParams, TaskTable } from '@/api/ReviewBusiness/01Project/projectType'
import { stagePageApi } from '@/api/01work/01stage'
import { StageList } from '@/api/01work/01type'
import * as echarts from 'echarts';
import { Result, StatusCode } from '@/utils/request';
import { EditType } from '@/type/BaseEnum'
import useInstance from '@/hooks/useInstance';
import { gethuResourList } from '@/api/test/test'
import { taskAnalyseStore } from '@/store/taskAnalyse'
export default function ProjectTable() {
    const { global, proxy } = useInstance()
    const store = taskAnalyseStore()
    let profitCharts = reactive<any>({})

    const ProjectData = reactive({
        list: [] as any,
        Loading: false,
        height: 0,
        title: [] as any,
        total: 0
    })
    const dictDateList = ref<any>({})
    // 查询参数
    let searchParams = reactive<TaskPageParams>({
        page: 1,
        size: 10,
        name: '',
        sort: ''
    })
    const stageParams = reactive<StageList>({
        page: 1,
        size: 100,
        name: ''
    })
    const gethuResourData = async () => {
        ProjectData.title = []
        const res = await gethuResourList()
        if (res.code === 200) {
            console.log(Object.keys(res.data));
            ProjectData.list = res.data
            ProjectData.total = Object.keys(res.data).length
            store.taskChange(ProjectData.list)
            // ProjectData.title.map(item=>)
            Object.keys(ProjectData.list).map(item => {
                console.log(item);
            })
        }
    }
    onMounted(() => {
        gethuResourData()
        nextTick(() => {
            ProjectData.height = window.innerHeight - 185
        })
    })
    let stageTableData = reactive<any>({
        list: [],
        table: [],
        Loading: false
    })
    const handleSizeChange = (size) => {
        searchParams.size = size
    }
    const tableRowClassName = ({ row, rowIndex }) => {
        if (rowIndex % 2 === 1) {
            return "warning-row";
        } else {
            return "success-row";
        }
    }
    const handleCurrentChange = (current) => {
        searchParams.page = current
    }

    return {
        ProjectData, searchParams, dictDateList, handleSizeChange, handleCurrentChange, stageTableData, tableRowClassName, profitCharts,
    }
}
